package com.fourth.controller.api;

import com.ljx.utils.OssUtil1;
import com.ljx.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author xiaoZhu
 * @version 1.0
 * @date 2023/3/3 20:06
 */
@Api(value = "commodity/api/oss", tags = {""})
@RestController
@RequestMapping("commodity/api/oss")
public class ApiOssController {

    /**
     * oss图片上传
     * @param file
     * @return
     * @throws Exception
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "form", dataType = "file", name = "file", value = "", required = true)
    })
    @ApiOperation(value = "oss图片上传", notes = "oss图片上传")
    @RequestMapping("/upload")
    @ResponseBody
    public Result upload(MultipartFile file) throws Exception {
        String path = OssUtil1.ossUpload(file);
        return new Result(200,"上传成功",path);
    }
}
